<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<title>登录页面</title>
</head>
<body> 
	<div style="margin-top: 200px;">
		<h2 style="text-align: center;">考试登录系统</h2>
		<form action = "" method = "post" name='a' style="text-align: center;" onsubmit="return check() " class="form-horizontal" role="form">
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">用户名:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "username"></div>
			</div>
			<div class="form-group">
				<div class="col-sm-3"></div>
				<label  class="col-sm-2 control-label">密码:</label>
				<div class="col-sm-2"><input class="form-control" type = "text" name = "password"></div>
			</div>
			<label><input type = "submit" value = "  登陆  " name = "subl" class="btn btn-primary" style="width: 150px"></label></br>		
			</br><a href = "注册.php">没有账号，立即注册</a></br>
		</form>
		<div style="margin-top: 100px;text-align: center;"><img src="img/福州大学至诚学院8字.png" width="50%"/></div>
		</div>
</body>
<script> 
// 表单判断
	function check() 
	{ 
	if(!(document.a.username.value.length)) 
	{ 
	alert("用户名不能为空！"); 
	document.a.username.focus(); 
	return false; 
	}
	if(!(document.a.password.value.length))
	{ 
	alert("密码不能为空！"); 
	document.a.password.focus(); 
	return false; 
	}

	} 

</script>
</html>
<?php
include_once("conn.php");   
if(isset($_POST["subl"])){
$id=$_POST['username'];
$pwd=$_POST['password'];
$search=mysqli_query($conn,"select * from useu where user='$id' ");
$get=mysqli_fetch_array($search);
if($get){
	if(($get['key'])==$pwd){
		if(($get['stu_or_ter'])==1){              //判断登录账号身份
			header("Location:管理.php");    
		}
		else if(($get['stu_or_ter'])==0){
			header("Location:学生查询.php");
		}
		else{
			header("Location:loginfal.php");        //登录失败跳转
		}
	}
	else{
		header("Location:loginfal.php");        //登录失败跳转
	}

}
else{
		header("Location:loginfal.php");        //登录失败跳转
	}
}
?>